package com.rpframework.utils;

import org.apache.commons.lang.StringUtils;

public class StringUtil {
	/**
	 * Checks if none of the CharSequences are blank ("") or null and whitespace
	 * only.. StringUtils.isNoneBlank(null) = false
	 * StringUtils.isNoneBlank(null, "foo") = false
	 * StringUtils.isNoneBlank(null, null) = false StringUtils.isNoneBlank("",
	 * "bar") = false StringUtils.isNoneBlank("bob", "") = false
	 * StringUtils.isNoneBlank("  bob  ", null) = false StringUtils.isNoneBlank(
	 * " ", "bar") = false StringUtils.isNoneBlank("foo", "bar") = true
	 * StringUtils.isNoneBlank([]) = false
	 * 
	 * @param string
	 * @return
	 */
	public static boolean isBlank(String... string) {
		if (string == null || string.length <= 0) {
			return true;
		}
		for (String str : string) {
			if (StringUtils.isBlank(str)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 判断字符串是否相等
	 * 
	 * @param string
	 *            字符
	 * @return 是返回true
	 */
	public static boolean equals(String... string) {
		if (string != null && string.length > 0) {
			for (int i = 0; i < string.length; i++) {
				String str = string[i];
				if (i < string.length - 1) {
					if (!StringUtils.equals(str, string[i + 1])) {
						return false;
					}
				}
			}
		}
		return true;
	}

	/**
	 * 判断字符串是否不相等
	 * 
	 * @param string
	 *            字符
	 * @return 是返回true
	 */
	public static boolean equalsNo(String... string) {
		if (string != null && string.length > 0) {
			for (int i = 0; i < string.length; i++) {
				String str = string[i];
				if (i < string.length - 1) {
					if (StringUtils.equals(str, string[i + 1])) {
						return false;
					}
				}
			}
		}
		return true;
	}
}
